<?php
declare (strict_types = 1);

namespace app\shop\controller;

use app\common\service\GoodsService\GoodsTagsService;
use app\Normal;
use think\annotation\Route;
use think\annotation\route\Group;
use think\annotation\route\Middleware;

/**
 * 商品标签
 * @Group("GoodsTag")
 * @Middleware({shopMiddileware::class})
 */
class GoodsTag extends \app\BaseShopController
{
    /**
     * @Route("tagLists",method="GET")
     * @return void
     */
    public function tagLists(){
        $result = callApi(GoodsTagsService::class, 'tagLists',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 商品标签详情
     * @Route("tagsInfo/:id",method="GET")
     * @return void
     */
    public function tagsInfo(){
        $result = callApi(GoodsTagsService::class, 'tagsInfo',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 编辑标签描述
     * @return void
     */
    public function editTags(){
        $result = callApi(GoodsTagsService::class, 'editTags',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'编辑ID为【'.$this->_all_data['id'].'】的商品标签','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }

    /**
     * 小程序标签显示详情
     * @Route("showTags",method="GET")
     * @return void
     */
    public function showTags(){
        $result = callApi(GoodsTagsService::class, 'showTags',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 全部标签列表
     * @Route("allTagslists",method="GET")
     * @return void
     */
    public function allTagslists(){
        $result = callApi(GoodsTagsService::class, 'allTagslists',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 设置小程序标签显示
     * @Route("setShowTags",method="POST")
     * @return void
     */
    public function setShowTags(){
        $result = callApi(GoodsTagsService::class, 'setShowTags',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'设置标签ID为【'.$this->_all_data['id'].'】的标签显示','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }
    
    /**
     * @Route("tagListsNoPage",method="GET")
     * @return void
     */
    public function tagListsNoPage(){
        $result = callApi(GoodsTagsService::class, 'tagListsNoPage',$this->_all_data);
        return apiResponse($result);
    }

}